﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace INSTA.BankSystem.BLL
{
    /// <summary>
    /// Factory class for all AccountBase-derived classes.
    /// </summary>
    public static class AccountFactory
    {
        internal static AccountBase Create(Customer customer, double deposit)
        {
            AccountBase result = null;

            if (deposit >= 0 && deposit < 10)
            {
                result = new StandardAccount(customer, deposit);
            }
            else if (deposit >= 10 && deposit < 100)
            {
                result = new SilverAccount(customer, deposit);
            }
            else if (deposit >= 100 )
            {
                result = new GoldAccount(customer, deposit);
            }
            else //---> Dépot négatif
            {
                string message = "Le dépot initial doit être supérieur ou égal à 0";

                // On lève une Exception de type NegativeDepositException
                throw new NegativeDepositException(message);
            }
            

            // Let's return the newly created Account..
            return result;
        }
    }
}
